<%-- 
    Document   : nuevo
    Created on : 05-16-2009, 03:55:03 AM
    Author     : alphyon
--%>
<%@page import="entidades.Pc" %>
<%@page import="entidades.Caracteristicas" %>
<%@page import="java.util.LinkedList" %>
<jsp:useBean id="pcc" scope="page" class="entidades.controladores.PcJDBC" />
<jsp:useBean id="caractc" scope="page" class="entidades.controladores.CaracteristicasJDBC" />
<jsp:useBean id="comp" scope="page" class="entidades.ComponentesPc" />
<jsp:useBean id="compc" scope="page" class="entidades.controladores.ComponentesPcJDBC" />
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <table>
            <form id="compu" name="comp" method="post" action="nuevo.jsp">
            <tr>
                <td>Identificador de Computadora</td>
                <td>
                    <select name="idpc">
                    <option>---</option>
                   <%
                        LinkedList<Pc> lisu = pcc.getPc();
                        for(int i=0; i < lisu.size();i++){
                            out.print("<option value='"+lisu.get(i).getIdEquipo()+"'>"+lisu.get(i).getNombreAsignado()+", "+lisu.get(i).getCodUbicacion()+"</option>");
                        }
                %>
                    </select>
                </td>
            </tr>
            <tr>
                <td>Identificador de Componente</td>
                 <td>
                   <select name="idcompo">
                   <option>---</option>
                   <%
                        LinkedList<Caracteristicas> lisc = caractc.getCaracteristicas();
                        for(int i=0; i < lisc.size();i++){
                            out.print("<option valuee='"+lisc.get(i).getIdEquipo()+"'>"+lisc.get(i).getIdTipo()+", "+lisc.get(i).getMarca()+"</option>");
                        }
                    %>
                    </select>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <input type="submit" name="bot" id="bot" value="Enviar" />
                    <input type="reset" name="bot2" id="bot2" value="Restablecer" />
                  </td>
            </tr>
           </form>
    </table>
<%
if(request.getParameter("bot")!=null){
    comp.setId(0);
    comp.setIdComponente(request.getParameter("idcompo"));
    comp.setIdPc(request.getParameter("idpc"));

    if(compc.crearComponentesPc(comp)==1){
        out.print("Componente asignado");
        }else{
        out.print("Componente no Asignadp");

        }

    }else{
out.print("");
    }
%>
    </body>
</html>
